/**
 * 文章基本信息表
 *
 */
module.exports = app => {
	const { STRING, INTEGER, CHAR, Sequelize } = app.Sequelize;
	const Category = app.model.define(
		'category',
		{
			id: {
				type: INTEGER,
				primaryKey: true,
				autoIncrement: true
			},
			//分类名称
			catename: {
				type: STRING(100),
				notNull: true,
				field: 'catename'
			},
			//分类别名
			alias: {
				type: STRING(100),
				notNull: true,
				field: 'alias'
			},
			//图标地址
			img: {
				type: STRING(100),
				field: 'img'
			},
			//链接地址
			link: {
				type: STRING(100),
				field: 'link'
			}
		},
		{
			timestamps: false, //去除createAt updateAt
			freezeTableName: true //使用自定义表名
		}
	);

	Category.associate = function() {
		app.model.Category.hasMany(app.model.Article, { foreignKey: 'id', targetKey: 'categoryId' });
	};
	return Category;
};
